<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
    <!-- 最新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap.min.css">

    <!-- 可选的Bootstrap主题文件（一般不用引入） -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap-theme.min.css">

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
    <!-- 自己服务器上的markdown的js文件 -->
    <script src="http://47.94.165.122/MarkdownIME.js"></script>
    <script src="http://47.94.165.122/showdown.min.js"></script>
    <style media="screen">
        .shadow {position:fixed; width:100%; height:100%; background:#000; opacity:0.3; filter:alpha(opacity:30);left:0; top: 0;}
        .mod_dialog {    width: 80%;
            height: 80%;
            border: 1px solid black;
            background: #fff;
            position: fixed;
            left: 10%;
            top: 16%;
        }
    </style>
    <script>
        function compile(){
            var text = document.getElementById("content").value;
            var converter = new showdown.Converter();
            var html = converter.makeHtml(text);
            document.getElementById("result").innerHTML = html;
        }
    </script>
</head>
<body>
<div class="page">
    <ul class="nav nav-tabs">
        <li role="presentation"> <a href="/admin/">管理首页</a></li>
        <li role="presentation"><a href="/admin/banners">banner设置</a></li>
        <li role="presentation"><a href="/admin/custom">custom</a></li>
        <li role="presentation" class="active"><a href="/admin/blog">blog</a></li>
        <li role="presentation"><a href="/admin/contact">联系方式</a></li>
        <li role="presentation"><a href="/admin/msg">留言管理</a></li>
        <li role="presentation"><a href="/admin/aboutMe">我的信息</a></li>
    </ul>
    <div class="content-wrap">
        <div>
            <form action="?" method="post" enctype="multipart/form-data" role="form">
                <label for="title"> 标题：</label>
                <input type="text" name="title" id="title" class="form-control" placeholder="请输入标题内容"/>
                <label for="description"> 描述：</label>
                <textarea name="description" id="description" class="form-control" rows="5" placeholder="输入描述内容"></textarea>
                <label for="f1"> 图片：</label>
                <input type="file" name="f1" id="f2" placeholder="选择文件"/>
                <label for="content"> 内容：</label>
                <textarea id="content"  name="content" class="form-control" rows="10" onkeyup="compile()">
                </textarea>
                <div id="result"></div>
                <label for="author"> 作者定的类型：(0=>HTML,1=>CSS,2=>JS,3=>Node,4=>其他)</label>
                <input type="text" name="author" id="author" class="form-contrl"/><br>
                <button type="submit" class="btn btn-default">添加</button>
            </form>
        </div>
        <table border="1" width="100%">
            <thead>
            <tr>
                <th>ID</th>
                <th>标题</th>
                <th>描述</th>
                <th>头像</th>
                <th>内容</th>

                <th>作者的类型</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <% for(var i=0;i<blogdata.length;i++){ %>
            <tr>
                <td><%=blogdata[i].ID%></td>
                <td><%=blogdata[i].title%></td>
                <td><%=blogdata[i].description%></td>
                <td><img width="32" height="32" src="/upload/<%=blogdata[i].src%>"/></td>
                <td><%=blogdata[i].content%></td>

                <td><%=blogdata[i].author%></td>
                <td>
                    <a href="?act=mod&id=<%=blogdata[i].ID%>">修改</a><br>
                    <a href="?act=del&id=<%=blogdata[i].ID%>" onclick="return confirm('你真的要删吗？')">删除</a>
                </td>
            </tr>
            <% } %>
            </tbody>
        </table>
        <% if(typeof mod_data!='undefined'){ %>
        <div class="shadow"></div>
        <div class="mod_dialog">
            <form action="?" method="post" enctype="multipart/form-data">
                <input type="hidden" name="mod_id" value="<%= mod_data.ID %>" />
                <label for="titlechange"> 标题：</label>
                <input type="text" id="titlechange" name="title" class="form-control" value="<%= mod_data.title %>" />
                <label for="deschange"> 描述：</label>
                <textarea name="description" id="deschange" class="form-control" rows="5"><%= mod_data.description %></textarea>
                <label for="srcchange"> 图片：</label>
                <input type="file" name="f2" id="srcchange" class="form-control"/>
                <label for="neirongchange"> 内容：</label>
                <textarea name="content" id="neirongchange" class="form-control" rows="10"><%= mod_data.content %></textarea><br>
                <label for="authorchange"> 作者规定的类型：(0=>HTML,1=>CSS,2=>JS,3=>Node,4=>其他)</label>
                <input type="text" name="author" id="authorchange" class="form-control" value="<%= mod_data.author %>" /><br>
                <input type="submit" value="修改"/>
                <a href="/admin/blog">取消修改</a>
            </form>
        </div>
        <% } %>
    </div>
</div>
</body>
</html>
